<?php
include 'core/Parser.php';
include 'core/SimpleInterpreter.php';

class Shorp{
	var $content = '';
	var $parser;
	var $interpreter;
	
	public function addAll($arr){
		foreach($arr as $src){
			$this->add($src);
		}
	}
	
	public function add($source){
		if(file_exists($source)){
			$this->content .= file_get_contents($source);
		}else{
			$this->content .= $source;
		}
	}
	
	public function parser($parser){
		$this->parser = $parser;
	}
	
	public function interpreter($interpreter){
		$this->interpreter = $interpreter;
	}
	
	public function run(){
		if(NULL == $this->parser){
			$this->parser = new Parser();
		}
		if(NULL == $this->interpreter){
			$this->interpreter = new SimpleInterpreter();
		}
		
		$root = $this->parser->parse($this->content);
		$result = $this->interpreter->interpret($root);
		
		return $result;
	}
}